package com.bothin.experiment4.dto;

import com.bothin.experiment4.enums.ContactStatusEnum;
import com.bothin.experiment4.utils.EnumUtil;
import com.bothin.experiment4.utils.serializer.Date2LongSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by bothin
 * At 2019/12/17 16:30
 * Description:
 */
@Data
public class ContactDTO  {
    private String contactId;
    private String customerId;
    private Integer employeeId;
    /**
     * 合同履行状态, 默认为未履行
     */
    private Integer performanceStatus;
    /**
     * 总价格
     */
    private BigDecimal money;
    /**
     * 创建时间
     */
    @JsonSerialize(using = Date2LongSerializer.class)
    private Date createTime;


    private String customerName;
    private String employeeName;
    private List<ContactDetailDTO> contactDetailDTOList;
    List<ProductFormDTO> productFormDTOList;

    public ContactStatusEnum getPerformanceStatusEnum(){
        return EnumUtil.getByCode(performanceStatus,ContactStatusEnum.class);
    }

    public String getCreateTime() {
        if (createTime!=null)
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
        else
            return "";
    }
}
